<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
     :root{
         --wight:100;
         --height:50;
     }
     .btn{
         width: calc(var(--wight)*1px);
         height: calc(var(--height)*1px);
         border:1px solid black;
         background-color:transparent;
         float: left;
         margin:0 5px
     }
     .btn:hover{
        color:var(--color,white);
        background-color: var(--bgColor,black);
        border:1px solid var(--borderColor,black);
     }

     .btn.red{
        --bgColor:red;
        --borderColor:red
     }
     .btn.yellow{
        --bgColor:yellow;
        --borderColor:yellow;
        
     }
     .btn.blue{
        --bgColor:blue;
        --borderColor:blue;
     }
    
    
    
    </style>
</head>
<body>
    <div class="btn">默认样式</div>
    <div class="btn red">红色</div>
    <div class="btn yellow">黄色</div>
    <div class="btn blue">蓝色</div>
</body>
</html>